Binary Tree Level Order Traversal from Right to Left
Easy
Question
Given the root of a tree, return a list of lists of the node values in the tree in level order traversal from right to left (top to bottom, right to left).
Input: root = [1, 2, 3, 4, None, 6, 7]
Output: [[1], [3, 2], [7, 6, 4]]
Input: root = [5, 9, None]
Output: [[5], [9]]
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
What is the expected output if the given tree is the following? [10, 5, 15, 3, 7, None, 18]
[[10], [5, 15], [3, 7, 18]]
[[10], [5, 15], [18, None, 7, 3]]
[[18, 7, 3], [15, 5], [10]]
[[10], [15, 5], [18, 7, 3]]
All test cases pass! 🎉
Time limit exceeded
InputExpected OutputActual Output
Standard OutputScroll down...
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.